package lelouet.sh3d.plugins.sweetDatacenter.model;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * a main class to show how the value2color function in gridlib scales the color
 * to the values
 */
public class ShowGraphicalRange extends JFrame {

	protected JPanel panel = new JPanel() {

		private static final long serialVersionUID = 1L;

		@Override
		public void paintComponent(Graphics g) {
			int width = getWidth();
			int step = 1;
			if (step < 1) {
				step = 1;
			}
			for (int x = 0; x < width; x += step) {
				g.setColor(new Color(GridGraphicalBridge.value2colorRGB(0, x,
						width)));
				g.fillRect(x, 0, step, getHeight() / 2);
				g.setColor(new Color(GridGraphicalBridge.value2colorRG(0, x,
						width)));
				g.fillRect(x, getHeight() / 2, step, getHeight() / 2);
			}
		}

	};

	public ShowGraphicalRange() {
		add(panel);
	}

	private static final long serialVersionUID = 1L;

	public static void main(String args[]) {
		ShowGraphicalRange window = new ShowGraphicalRange();
		window.setDefaultCloseOperation(EXIT_ON_CLOSE);
		window.setSize(new Dimension(800, 600));
		window.setVisible(true);
	}

}
